unit uNFEAlfasig;

interface

uses
  SysUtils, Classes, DB, DBClient;      

type
  TdmNFEAlfasig = class(TDataModule)
    A: TClientDataSet;
    B: TClientDataSet;
    B13: TClientDataSet;
    B14: TClientDataSet;
    Aversao: TFloatField;
    AId: TStringField;
    BcUF: TIntegerField;
    BcNF: TIntegerField;
    BnatOp: TStringField;
    BindPag: TIntegerField;
    Bmod: TStringField;
    Bserie: TIntegerField;
    BnNF: TIntegerField;
    BdEmi: TDateField;
    BdSaiEnt: TDateField;
    BtpNF: TIntegerField;
    BcMunFG: TIntegerField;
    BtpImp: TIntegerField;
    BtpEmis: TIntegerField;
    BcDV: TIntegerField;
    BtpAmb: TIntegerField;
    BfinNFe: TIntegerField;
    BprocEmi: TIntegerField;
    B14cUF: TIntegerField;
    BverProc: TStringField;
    B14AAMM: TIntegerField;
    B14CNPJ: TStringField;
    B14mod: TIntegerField;
    B14serie: TIntegerField;
    B14nNF: TIntegerField;
    C: TClientDataSet;
    C02: TClientDataSet;
    C02a: TClientDataSet;
    C05: TClientDataSet;
    E: TClientDataSet;
    E02: TClientDataSet;
    E03: TClientDataSet;
    E05: TClientDataSet;
    G: TClientDataSet;
    H: TClientDataSet;
    CxNome: TStringField;
    CxFant: TStringField;
    CIE: TStringField;
    CIEST: TStringField;
    CIM: TStringField;
    CCNAE: TStringField;
    C02CNPJ: TStringField;
    C02aCPF: TStringField;
    C05xLgr: TStringField;
    C05nro: TStringField;
    C05xCpl: TStringField;
    C05xBairro: TStringField;
    C05cMun: TIntegerField;
    C05xMun: TStringField;
    C05UF: TStringField;
    C05CEP: TIntegerField;
    C05cPais: TIntegerField;
    C05xPais: TStringField;
    ExNome: TStringField;
    EIE: TStringField;
    EISUF: TStringField;
    E02CNPJ: TStringField;
    E03CPF: TStringField;
    E05xLgr: TStringField;
    E05nro: TStringField;
    E05xCpl: TStringField;
    E05cMun: TIntegerField;
    E05xMun: TStringField;
    E05UF: TStringField;
    E05CEP: TIntegerField;
    E05cPais: TIntegerField;
    E05xPais: TStringField;
    I: TClientDataSet;
    N02: TClientDataSet;
    N03: TClientDataSet;
    N04: TClientDataSet;
    N05: TClientDataSet;
    N06: TClientDataSet;
    N07: TClientDataSet;
    N08: TClientDataSet;
    N09: TClientDataSet;
    N10: TClientDataSet;
    P: TClientDataSet;
    GCNPJ: TStringField;
    GxLgr: TStringField;
    Gnro: TStringField;
    GxCpl: TStringField;
    GxBairro: TStringField;
    GcMun: TIntegerField;
    GxMun: TStringField;
    GUF: TStringField;
    HnItem: TIntegerField;
    HinfAdItem: TStringField;
    IcProd: TStringField;
    IcEan: TStringField;
    IxProd: TStringField;
    INCM: TStringField;
    IEXTIPI: TStringField;
    Igenero: TIntegerField;
    ICFOP: TIntegerField;
    IuCom: TStringField;
    IqCom: TFloatField;
    IvUnCom: TFloatField;
    IvProd: TFloatField;
    IcEANTrib: TStringField;
    IuTrib: TStringField;
    IqTrib: TFloatField;
    IvUnTrib: TFloatField;
    IvFrete: TFloatField;
    IvSeg: TFloatField;
    IvDesc: TFloatField;
    N02orig: TIntegerField;
    N02CST: TIntegerField;
    N02modBC: TIntegerField;
    N02vBC: TFloatField;
    N02pICMS: TFloatField;
    N02vICMS: TFloatField;
    N03orig: TIntegerField;
    N03CST: TIntegerField;
    N03modBC: TIntegerField;
    N03vBC: TFloatField;
    N03pICMS: TFloatField;
    N03vICMS: TFloatField;
    N03modBCST: TIntegerField;
    N03pMVAST: TFloatField;
    N03pRedBCST: TFloatField;
    N03vBCST: TFloatField;
    N03pICMSST: TFloatField;
    N03vICMSST: TFloatField;
    N04orig: TIntegerField;
    N04CST: TIntegerField;
    N04modBC: TIntegerField;
    N04pRedBC: TFloatField;
    N04vBC: TFloatField;
    N04pICMS: TFloatField;
    N04vICMS: TFloatField;
    N05orig: TIntegerField;
    N05CST: TIntegerField;
    N05modBCST: TIntegerField;
    N05pMVAst: TFloatField;
    N05pRedBCST: TFloatField;
    N05vBCST: TFloatField;
    N05pICMSST: TFloatField;
    N05vICMSST: TFloatField;
    N06orig: TIntegerField;
    N06CST: TIntegerField;
    N07orig: TIntegerField;
    N07CST: TIntegerField;
    N07modBC: TIntegerField;
    N07pRedBC: TFloatField;
    N07vBC: TFloatField;
    N07pICMS: TFloatField;
    N07vICMS: TFloatField;
    N08orig: TIntegerField;
    N08CST: TIntegerField;
    N08vBCST: TFloatField;
    N08vICMSST: TFloatField;
    N09orig: TIntegerField;
    N09CST: TIntegerField;
    N09modBC: TIntegerField;
    N09pRedBC: TFloatField;
    N09vBC: TFloatField;
    N09pICMS: TFloatField;
    N09vICMS: TFloatField;
    N09modBCST: TIntegerField;
    N09pMVAST: TFloatField;
    N09pRedBCST: TFloatField;
    N09vBCST: TFloatField;
    N09pICMSST: TFloatField;
    N09vICMSST: TFloatField;
    N10orig: TIntegerField;
    N10CST: TIntegerField;
    N10modBC: TIntegerField;
    N10pRedBC: TFloatField;
    N10vBC: TFloatField;
    N10pICMS: TFloatField;
    N10modBCST: TIntegerField;
    N10pMVAST: TFloatField;
    N10pRedBCST: TFloatField;
    N10vBCST: TFloatField;
    N10pICMSST: TFloatField;
    N10vICMSST: TFloatField;
    PvBC: TFloatField;
    PvDespAdu: TFloatField;
    PvII: TFloatField;
    PvIOF: TFloatField;
    Bregistro: TStringField;
    Cregistro: TStringField;
    Eregistro: TStringField;
    N: TClientDataSet;
    Nregistro: TStringField;
    O: TClientDataSet;
    OclEnq: TStringField;
    OCNPJProd: TStringField;
    OcSelo: TStringField;
    OqSelo: TIntegerField;
    OcEnq: TStringField;
    Oregistro: TStringField;
    O07: TClientDataSet;
    O10: TClientDataSet;
    O11: TClientDataSet;
    O08: TClientDataSet;
    O07CST: TStringField;
    O07vIPI: TFloatField;
    O10vBC: TFloatField;
    O10pIPI: TFloatField;
    O11vUnid: TFloatField;
    O11qUnid: TFloatField;
    O08CST: TStringField;
    E05xBairro: TStringField;
    W02: TClientDataSet;
    W02vBC: TFloatField;
    W02vST: TFloatField;
    W02vProd: TFloatField;
    W02vFrete: TFloatField;
    W02vSeg: TFloatField;
    W02vDesc: TFloatField;
    W02vII: TFloatField;
    W02vPIS: TFloatField;
    W02vCOFINS: TFloatField;
    W02vOutro: TFloatField;
    W02vNF: TFloatField;
    W02vIPI: TFloatField;
    X: TClientDataSet;
    XmodFrete: TIntegerField;
    Xregistro: TStringField;
    X03: TClientDataSet;
    X03IE: TStringField;
    X03xEnder: TStringField;
    X03UF: TStringField;
    X03xMun: TStringField;
    X26: TClientDataSet;
    X26qVol: TIntegerField;
    X26esp: TStringField;
    X26marca: TStringField;
    X26nVol: TStringField;
    X26pesoL: TFloatField;
    X26pesoB: TFloatField;
    Y: TClientDataSet;
    Y02: TClientDataSet;
    Z: TClientDataSet;
    Y07: TClientDataSet;
    ZA: TClientDataSet;
    ZB: TClientDataSet;
    Z10: TClientDataSet;
    Yregistro: TStringField;
    Y02nFat: TStringField;
    Y02vOrig: TFloatField;
    Y02vDesc: TFloatField;
    Y02vLiq: TFloatField;
    Y07nDup: TStringField;
    Y07dVenc: TDateField;
    Y07vDup: TFloatField;
    ZinfAdFisco: TStringField;
    ZinfCpl: TStringField;
    Zregistro: TStringField;
    Z10nProc: TStringField;
    Z10indProc: TIntegerField;
    ZAUFEmbarq: TStringField;
    ZAxLocEmbarq: TStringField;
    ZBxNFEmp: TStringField;
    ZBxPed: TStringField;
    ZBxCont: TStringField;
    M: TClientDataSet;
    W: TClientDataSet;
    W02vBCST: TFloatField;
    X03xNome: TStringField;
    X05: TClientDataSet;
    X04: TClientDataSet;
    X04CNPJ: TStringField;
    X05CPF: TStringField;
    Q: TClientDataSet;
    Q04: TClientDataSet;
    S: TClientDataSet;
    S04: TClientDataSet;
    Qregistro: TStringField;
    Q04CST: TIntegerField;
    Sregistro: TStringField;
    S04CST: TIntegerField;
    X18: TClientDataSet;
    X18placa: TStringField;
    X18UF: TStringField;
    X18RNTC: TStringField;
    Z04: TClientDataSet;
    Z04xCampo: TStringField;
    Z04xTexto: TStringField;
    E05fone: TStringField;                                
    Mregistro: TStringField;
    Wregistro: TStringField;
    NOTAFISCAL: TClientDataSet;
    NOTAFISCALqtd: TIntegerField;
    W02vICMS: TFloatField;
    B13refNFe: TStringField;
    C05fone: TStringField;
    procedure DataModuleCreate(Sender: TObject);
    procedure DataModuleDestroy(Sender: TObject);
    procedure X18BeforePost(DataSet: TDataSet);
    procedure NOTAFISCALBeforePost(DataSet: TDataSet);
    procedure ABeforePost(DataSet: TDataSet);
    procedure BBeforePost(DataSet: TDataSet);
    procedure B13BeforePost(DataSet: TDataSet);
    procedure B14BeforePost(DataSet: TDataSet);
    procedure CBeforePost(DataSet: TDataSet);
    procedure C02BeforePost(DataSet: TDataSet);
    procedure C02aBeforePost(DataSet: TDataSet);
    procedure C05BeforePost(DataSet: TDataSet);
    procedure EBeforePost(DataSet: TDataSet);
    procedure E02BeforePost(DataSet: TDataSet);
    procedure E03BeforePost(DataSet: TDataSet);
    procedure E05BeforePost(DataSet: TDataSet);
    procedure GBeforePost(DataSet: TDataSet);
    procedure HBeforePost(DataSet: TDataSet);
    procedure IBeforePost(DataSet: TDataSet);
    procedure MBeforePost(DataSet: TDataSet);
    procedure NBeforePost(DataSet: TDataSet);
    procedure N02BeforePost(DataSet: TDataSet);
    procedure N03BeforePost(DataSet: TDataSet);
    procedure N04BeforePost(DataSet: TDataSet);
    procedure N05BeforePost(DataSet: TDataSet);
    procedure N06BeforePost(DataSet: TDataSet);
    procedure N07BeforePost(DataSet: TDataSet);
    procedure N08BeforePost(DataSet: TDataSet);
    procedure N09BeforePost(DataSet: TDataSet);
    procedure N10BeforePost(DataSet: TDataSet);
    procedure OBeforePost(DataSet: TDataSet);
    procedure O07BeforePost(DataSet: TDataSet);
    procedure O10BeforePost(DataSet: TDataSet);
    procedure O11BeforePost(DataSet: TDataSet);
    procedure O08BeforePost(DataSet: TDataSet);
    procedure PBeforePost(DataSet: TDataSet);
    procedure QBeforePost(DataSet: TDataSet);
    procedure Q04BeforePost(DataSet: TDataSet);
    procedure SBeforePost(DataSet: TDataSet);
    procedure S04BeforePost(DataSet: TDataSet);
    procedure WBeforePost(DataSet: TDataSet);
    procedure W02BeforePost(DataSet: TDataSet);
    procedure XBeforePost(DataSet: TDataSet);
    procedure X03BeforePost(DataSet: TDataSet);
    procedure X04BeforePost(DataSet: TDataSet);
    procedure X05BeforePost(DataSet: TDataSet);
    procedure X26BeforePost(DataSet: TDataSet);
    procedure YBeforePost(DataSet: TDataSet);
    procedure Y02BeforePost(DataSet: TDataSet);
    procedure Y07BeforePost(DataSet: TDataSet);
    procedure ZBeforePost(DataSet: TDataSet);
    procedure Z04BeforePost(DataSet: TDataSet);
    procedure Z10BeforePost(DataSet: TDataSet);
    procedure ZABeforePost(DataSet: TDataSet);
    procedure ZBBeforePost(DataSet: TDataSet);

  private
    { Private declarations }
    procedure verificaRequeridos(var cds:TClientDataSet);

  public
    { Public declarations }

  end;

var
  dmNFEAlfasig: TdmNFEAlfasig;
  stlErro:TStringList;

implementation

{$R *.dfm}

procedure TdmNFEAlfasig.DataModuleCreate(Sender: TObject);
begin
  stlErro := TStringList.Create;
end;

procedure TdmNFEAlfasig.DataModuleDestroy(Sender: TObject);
begin
  FreeAndNil(stlErro);
end;

procedure TdmNFEAlfasig.verificaRequeridos(var cds: TClientDataSet);
var
  i:integer;

begin
  for i := 0 to cds.Fields.Count - 1 do begin
    if (cds.Fields[i].Required) then begin
      if (cds.Fields[i].DataType = ftFloat) or (cds.Fields[i].DataType = ftInteger) then begin
        if (cds.Fields[i].IsNull) then begin
          cds.Fields[i].Value := 8534973;
        end;

      end else if (cds.Fields[i].DataType = ftString) then begin
        if (cds.Fields[i].Value = '') or (cds.Fields[i].IsNull) then begin
          cds.Fields[i].AsString := '##ERRO##';
        end;

      end else if (cds.Fields[i].DataType = ftDate) then begin
        if (cds.Fields[i].AsDateTime = 0) or (cds.Fields[i].IsNull) then begin
          cds.Fields[i].AsDateTime := StrToDate('27/12/2999');
        end;

      end;

    end;

  end;

end;

procedure TdmNFEAlfasig.X18BeforePost(DataSet: TDataSet);
begin
  verificaRequeridos(X18);
end;

procedure TdmNFEAlfasig.NOTAFISCALBeforePost(DataSet: TDataSet);
begin
  verificaRequeridos(NOTAFISCAL);
end;

procedure TdmNFEAlfasig.ABeforePost(DataSet: TDataSet);
begin
  verificaRequeridos(A);
end;

procedure TdmNFEAlfasig.BBeforePost(DataSet: TDataSet);
begin
  verificaRequeridos(B);
end;

procedure TdmNFEAlfasig.B13BeforePost(DataSet: TDataSet);
begin
  verificaRequeridos(B13);
end;

procedure TdmNFEAlfasig.B14BeforePost(DataSet: TDataSet);
begin
  verificaRequeridos(B14);
end;

procedure TdmNFEAlfasig.CBeforePost(DataSet: TDataSet);
begin
  verificaRequeridos(C);
end;

procedure TdmNFEAlfasig.C02BeforePost(DataSet: TDataSet);
begin
  verificaRequeridos(C02);
end;

procedure TdmNFEAlfasig.C02aBeforePost(DataSet: TDataSet);
begin
  verificaRequeridos(C02a);
end;

procedure TdmNFEAlfasig.C05BeforePost(DataSet: TDataSet);
begin
  verificaRequeridos(C05);
end;

procedure TdmNFEAlfasig.EBeforePost(DataSet: TDataSet);
begin
  verificaRequeridos(E);
end;

procedure TdmNFEAlfasig.E02BeforePost(DataSet: TDataSet);
begin
  verificaRequeridos(E02);
end;

procedure TdmNFEAlfasig.E03BeforePost(DataSet: TDataSet);
begin
  verificaRequeridos(E03);
end;

procedure TdmNFEAlfasig.E05BeforePost(DataSet: TDataSet);
begin
verificaRequeridos(E05);
end;

procedure TdmNFEAlfasig.GBeforePost(DataSet: TDataSet);
begin
  verificaRequeridos(G);
end;

procedure TdmNFEAlfasig.HBeforePost(DataSet: TDataSet);
begin
verificaRequeridos(H);
end;

procedure TdmNFEAlfasig.IBeforePost(DataSet: TDataSet);
begin
  verificaRequeridos(I);
end;

procedure TdmNFEAlfasig.MBeforePost(DataSet: TDataSet);
begin
  verificaRequeridos(M);
end;

procedure TdmNFEAlfasig.NBeforePost(DataSet: TDataSet);
begin
  verificaRequeridos(N);
end;

procedure TdmNFEAlfasig.N02BeforePost(DataSet: TDataSet);
begin
  verificaRequeridos(N02);
end;

procedure TdmNFEAlfasig.N03BeforePost(DataSet: TDataSet);
begin
  verificaRequeridos(N03);
end;

procedure TdmNFEAlfasig.N04BeforePost(DataSet: TDataSet);
begin
  verificaRequeridos(N04);
end;

procedure TdmNFEAlfasig.N05BeforePost(DataSet: TDataSet);
begin
  verificaRequeridos(N05);
end;

procedure TdmNFEAlfasig.N06BeforePost(DataSet: TDataSet);
begin
  verificaRequeridos(N06);
end;

procedure TdmNFEAlfasig.N07BeforePost(DataSet: TDataSet);
begin
  verificaRequeridos(N07);
end;

procedure TdmNFEAlfasig.N08BeforePost(DataSet: TDataSet);
begin
  verificaRequeridos(N08);
end;

procedure TdmNFEAlfasig.N09BeforePost(DataSet: TDataSet);
begin
  verificaRequeridos(N09);
end;

procedure TdmNFEAlfasig.N10BeforePost(DataSet: TDataSet);
begin
  verificaRequeridos(N10);
end;

procedure TdmNFEAlfasig.OBeforePost(DataSet: TDataSet);
begin
  verificaRequeridos(O);
end;

procedure TdmNFEAlfasig.O07BeforePost(DataSet: TDataSet);
begin
  verificaRequeridos(O07);
end;

procedure TdmNFEAlfasig.O10BeforePost(DataSet: TDataSet);
begin
  verificaRequeridos(O10);
end;

procedure TdmNFEAlfasig.O11BeforePost(DataSet: TDataSet);
begin
  verificaRequeridos(O11);
end;

procedure TdmNFEAlfasig.O08BeforePost(DataSet: TDataSet);
begin
  verificaRequeridos(O08);
end;

procedure TdmNFEAlfasig.PBeforePost(DataSet: TDataSet);
begin
  verificaRequeridos(P);
end;

procedure TdmNFEAlfasig.QBeforePost(DataSet: TDataSet);
begin
  verificaRequeridos(Q);
end;

procedure TdmNFEAlfasig.Q04BeforePost(DataSet: TDataSet);
begin
  verificaRequeridos(Q04);
end;

procedure TdmNFEAlfasig.SBeforePost(DataSet: TDataSet);
begin
  verificaRequeridos(S);
end;

procedure TdmNFEAlfasig.S04BeforePost(DataSet: TDataSet);
begin
  verificaRequeridos(S04);
end;

procedure TdmNFEAlfasig.WBeforePost(DataSet: TDataSet);
begin
  verificaRequeridos(W);
end;

procedure TdmNFEAlfasig.W02BeforePost(DataSet: TDataSet);
begin
  verificaRequeridos(W02);
end;

procedure TdmNFEAlfasig.XBeforePost(DataSet: TDataSet);
begin
//  verificaRequeridos(X);
end;

procedure TdmNFEAlfasig.X03BeforePost(DataSet: TDataSet);
begin
//  verificaRequeridos(X03);
end;

procedure TdmNFEAlfasig.X04BeforePost(DataSet: TDataSet);
begin
//  verificaRequeridos(X04);
end;

procedure TdmNFEAlfasig.X05BeforePost(DataSet: TDataSet);
begin
//  verificaRequeridos(X05);
end;

procedure TdmNFEAlfasig.X26BeforePost(DataSet: TDataSet);
begin
//  verificaRequeridos(X26);
end;

procedure TdmNFEAlfasig.YBeforePost(DataSet: TDataSet);
begin
  verificaRequeridos(Y);
end;

procedure TdmNFEAlfasig.Y02BeforePost(DataSet: TDataSet);
begin
  verificaRequeridos(Y02);
end;

procedure TdmNFEAlfasig.Y07BeforePost(DataSet: TDataSet);
begin
  verificaRequeridos(Y07);
end;

procedure TdmNFEAlfasig.ZBeforePost(DataSet: TDataSet);
begin
  verificaRequeridos(Z);
end;

procedure TdmNFEAlfasig.Z04BeforePost(DataSet: TDataSet);
begin
  verificaRequeridos(Z04);
end;

procedure TdmNFEAlfasig.Z10BeforePost(DataSet: TDataSet);
begin
  verificaRequeridos(Z10);
end;

procedure TdmNFEAlfasig.ZABeforePost(DataSet: TDataSet);
begin
  verificaRequeridos(ZA);
end;

procedure TdmNFEAlfasig.ZBBeforePost(DataSet: TDataSet);
begin
  verificaRequeridos(ZB);
end;

end.
